<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>菜品列表</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="${pageContext.request.contextPath}/sources/css/font.css">
        <link rel="stylesheet" href="${pageContext.request.contextPath}/sources/css/xadmin.css">
        <script src="${pageContext.request.contextPath}/sources/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="${pageContext.request.contextPath}/sources/js/xadmin.js"></script>
        <script type="text/javascript" src="${pageContext.request.contextPath}/sources/scripts/jquery-3.4.1.min.js"></script>
        <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
        <script type="text/javascript">
function deletefood(food_id){
	
	var flag = confirm("确定要删除该条记录吗");
	if(flag){
		var url = "${pageContext.request.contextPath}/deleteFood";//请求地址
        var param = {food_id:food_id};
		$.post(url,param,function(data){
			if(data=="1"){
				location.reload();//重新刷新页面
			}
			
			
		});
		//发生ajax请求
		//alert(id)
	}
}

</script>

    </head>
    <body>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body ">
                            <form class="layui-form layui-col-space5">
                                 <div class="layui-inline layui-show-xs-block">
                                    <input type="text" name="username"  placeholder="请输入菜品名" autocomplete="off" class="layui-input">
                                </div>                           
                                <div class="layui-inline layui-show-xs-block">
                                    <input type="text" name="username"  placeholder="请输入菜品名" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-inline layui-show-xs-block">
                                    <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                                </div>
                            </form>
                        </div>
                        <div class="layui-card-header">
                            <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
                            <button class="layui-btn" onclick="xadmin.open('添加菜品','${pageContext.request.contextPath}/food_add',600,400)"><i class="layui-icon"></i>添加</button>
                        </div>
                        <div class="layui-card-body layui-table-body layui-table-main">
                            <table class="layui-table layui-form" id="table">
                                <thead>
                                  <tr>
                                    <th>
                                      <input type="checkbox" lay-filter="checkall" name="" lay-skin="primary">
                                    </th>
                                       <th>ID</th>
						              <th>食品名称</th>
								      <th>食品价格</th>
									  <th>食品图片</th>
									  <th>食品描述</th>
									  <th>食品预约量</th>
									  <th>食品评星</th>
									  <th>操作</th>
                                    </tr>
                                </thead>
                                <c:forEach items="${foodes }" var="item">
                                <tbody id="tbody">
                                  <tr>
                                    <td>
                                      <input type="checkbox" name="id" value="1"   lay-skin="primary"> 
                                    </td>
                                    <td>${item.food_id }</td>
                                    <td>${item.food_name}</td>
                                    <td>${item.food_price}</td>
                                    <td><img src="${pageContext.request.contextPath}/imgs/${item.food_picture}"/></td>
									<td>${item.food_desc}</td>
									<td>${item.food_number}</td>
									<td>${item.food_start}</td>
                                    <td class="td-manage">
                                      <a title="详情"  onclick="xadmin.open('详情','${pageContext.request.contextPath}/food_detail?food_id=${item.food_id}',600,400)" href="javascript:;">
                                        <i class="layui-icon">&#xe631;</i>
                                      </a>
                                      <a onclick="xadmin.open('修改','${pageContext.request.contextPath}/food_update?food_id=${item.food_id}',600,400)" title="修改" href="javascript:;">
                                        <i class="layui-icon">&#xe642;</i>
                                      </a>
                                      <a title="删除" onclick="deletefood(${item.food_id})">
                                        <i class="layui-icon">&#xe640;</i>
                                      </a>
                                    </td>
                                  </tr>
                                </tbody>
                                </c:forEach>
                            </table>
                        </div>
                        <div class="layui-card-body ">
                            <div class="page">
                                <div>
                                  <a class="prev" href="">&lt;&lt;</a>
                                  <a class="num" href="">1</a>
                                  <span class="current">2</span>
                                  <a class="num" href="">3</a>
                                  <a class="num" href="">489</a>
                                  <a class="next" href="">&gt;&gt;</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div> 
    </body>
   
</html>
</html>